package com.example.lt.config;

import com.example.lt.constant.PicConstant;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author 小涛Tao
 * @Date: 2024/05/30/20:33
 * version 1.0 注释：静态图片路径转换
 **/
@Configuration
public class WebPicConfig implements WebMvcConfigurer {

    /**
     * 这个配置类的目的是什么  就是注册了一个类似于拦截器吧  看到对应的资源 会将其修改成相应的地址
     * @param registry
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("//img/avatorImages/**")
                .addResourceLocations(PicConstant.AVATOR_IMAGES_PATH);
        registry.addResourceHandler("//img/singerPic/**")
                .addResourceLocations(PicConstant.SINGER_PIC_PATH);
        registry.addResourceHandler("//img/songPic/**")
                .addResourceLocations(PicConstant.SONG_PIC_PATH);
        registry.addResourceHandler("//song/**")
                .addResourceLocations(PicConstant.SONG_PATH);
        registry.addResourceHandler("//img/songListPic/**")
                .addResourceLocations(PicConstant.SONGLIST_PIC_PATH);
        registry.addResourceHandler("//img/swiper/**")
                .addResourceLocations(PicConstant.BANNER_PIC_PATH);
    }

}
